package com.example.combwyaq.mvp.presenter;

import com.example.combwyaq.R;
import com.example.combwyaq.entity.UserEntity;
import com.example.combwyaq.mvp.contract.UserContract;
import com.example.combwyaq.mvp.model.entity.BaseEntity;
import com.example.combwyaq.mvp.model.entity.UserItemEntity;
import com.example.combwyaq.mvp.model.entity.UserMenuEntity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.inject.Inject;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

public class UserPresenter extends BasePresenter<UserContract.IUserModel,UserContract.IUserView> {
    @Inject
    public UserPresenter(UserContract.IUserModel iUserModel, UserContract.IUserView iUserView) {
        super(iUserModel, iUserView);
    }

    //初始化数据方法
    public void initData(){
        List<UserMenuEntity> menuEntities=new ArrayList<>();
        menuEntities.add(new UserMenuEntity(R.drawable.res_icon7_274,"消息",null));
        menuEntities.add(new UserMenuEntity(R.drawable.res_icon7_275,"收藏",null));
        menuEntities.add(new UserMenuEntity(R.drawable.res_icon7_277,"评论",null));
        menuEntities.add(new UserMenuEntity(R.drawable.res_icon7_276,"历史",null));
        menuEntities.add(new UserMenuEntity(R.drawable.res_icon7_278,"关注",null));
        menuEntities.add(new UserMenuEntity(R.drawable.res_icon7_279,"下载",null));
        menuEntities.add(new UserMenuEntity(R.drawable.res_icon7_280,"公益",null));
        menuEntities.add(new UserMenuEntity(R.drawable.res_icon7_281,"问政",null));
        v.refreshMenu(menuEntities);
        List<UserItemEntity> itemEntitie=new ArrayList<>();
        itemEntitie.add(new UserItemEntity("积分商城",null));
        itemEntitie.add(new UserItemEntity("夜间模式",null));
        itemEntitie.add(new UserItemEntity("意见反馈",null));
        itemEntitie.add(new UserItemEntity("更多设置",null));
        v.refreshItemes(itemEntitie);
    }
    public void selUser(int user_id,int code){
        Map<String,Object> map=new HashMap<>();
        map.put("user_id",user_id);
        map.put("code",code);
        m.requestUser(map).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(this);
    }


    @Override
    public void onNext(BaseEntity baseEntity) {
       v.refresh(baseEntity);
    }
}
